/**
 * 随机数
 */
export const random = (min: number, max: number) => {
    return Math.floor(Math.random() * (max - min + 1) + min)
}

/**
 * 随机颜色
 */
export const randomColor = () => {
    return `#${Math.floor(Math.random() * 16777215).toString(16)}`
}

/**
 * 随机字符串
 */
export const randomStr = (length: number = 6) => {
    let result = ''
    const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
    const charactersLength = characters.length
    for (let i = 0; i < length; i++) {
        result += characters.charAt(Math.floor(Math.random() * charactersLength))
    }
    return result
}
